import 'package:flutter/material.dart';

import '../../application.dart';

class SettingPage extends StatefulWidget {
  const SettingPage({Key? key}) : super(key: key);

  @override
  State<SettingPage> createState() => _SettingPageState();
}

class _SettingPageState extends State<SettingPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('设置'),
      ),
      body: SafeArea(
        child: ListView(
          children: [
            ListTile(
              title: const Text('个人资料'),
              trailing: const Icon(Icons.chevron_right),
              enableFeedback: true,
              onTap: () {
                app.route('/member/profile');
              },
            ),
            const Divider(
              height: 0.5,
              indent: 20,
            ),
            ListTile(
              title: const Text('我的地址'),
              trailing: const Icon(Icons.chevron_right),
              enableFeedback: true,
              onTap: () {
                app.route('/member/addresses');
              },
            ),
            const Divider(
              height: 0.5,
              indent: 20,
            ),
            ListTile(
              title: const Text('修改密码'),
              trailing: const Icon(Icons.chevron_right),
              enableFeedback: true,
              onTap: () {
                app.route('/member/password');
              },
            ),
            const SizedBox(
              height: 10,
            ),
            ListTile(
              title: const Text('反馈留言'),
              trailing: const Icon(Icons.chevron_right),
              enableFeedback: true,
              onTap: () {
                app.route('/feedback');
              },
            ),
            const Divider(
              height: 0.5,
              indent: 20,
            ),
            ListTile(
              title: const Text('关于我们'),
              trailing: const Icon(Icons.chevron_right),
              enableFeedback: true,
              onTap: () {
                app.route('/about');
              },
            ),
            const SizedBox(
              height: 10,
            ),
            ListTile(
              title: const Text('清除缓存'),
              trailing: const Icon(Icons.chevron_right),
              enableFeedback: true,
              onTap: () {
                app.clearCache().then((value) => app.toast('清除成功'));
              },
            ),
            const SizedBox(
              height: 10,
            ),
            ListTile(
              title: const Center(
                child: Text('退出'),
              ),
              onTap: () async {
                await app.login.clearLogin();
                app.toast('退出成功');
                Navigator.pop(context);
              },
            )
          ],
        ),
      ),
    );
  }
}
